package b.l.a;

import android.os.Parcelable;
import android.view.View;
import android.view.ViewGroup;
import androidx.fragment.app.Fragment;
import b.n.d.b;
import b.u.a.a;
import java.util.Objects;

/* compiled from: FragmentPagerAdapter */
public abstract class n extends a {
    public final h c;
    public final int d;
    public p e = null;
    public Fragment f = null;

    public n(h hVar, int i) {
        this.c = hVar;
        this.d = i;
    }

    public static String m(int i, long j) {
        StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.append("android:switcher:");
        stringBuilder.append(i);
        stringBuilder.append(":");
        stringBuilder.append(j);
        return stringBuilder.toString();
    }

    public void a(ViewGroup viewGroup, int i, Object obj) {
        Fragment fragment = (Fragment) obj;
        if (this.e == null) {
            i iVar = (i) this.c;
            Objects.requireNonNull(iVar);
            this.e = new a(iVar);
        }
        this.e.e(fragment);
        if (fragment == this.f) {
            this.f = null;
        }
    }

    public void b(ViewGroup viewGroup) {
        p pVar = this.e;
        if (pVar != null) {
            pVar.d();
            this.e = null;
        }
    }

    public boolean g(View view, Object obj) {
        return ((Fragment) obj).G == view;
    }

    public void i(Parcelable parcelable, ClassLoader classLoader) {
    }

    public Parcelable j() {
        return null;
    }

    public void k(ViewGroup viewGroup, int i, Object obj) {
        Fragment fragment = (Fragment) obj;
        Fragment fragment2 = this.f;
        if (fragment != fragment2) {
            i iVar;
            if (fragment2 != null) {
                fragment2.g0(false);
                if (this.d == 1) {
                    if (this.e == null) {
                        iVar = (i) this.c;
                        Objects.requireNonNull(iVar);
                        this.e = new a(iVar);
                    }
                    this.e.h(this.f, b.STARTED);
                } else {
                    this.f.k0(false);
                }
            }
            fragment.g0(true);
            if (this.d == 1) {
                if (this.e == null) {
                    iVar = (i) this.c;
                    Objects.requireNonNull(iVar);
                    this.e = new a(iVar);
                }
                this.e.h(fragment, b.RESUMED);
            } else {
                fragment.k0(true);
            }
            this.f = fragment;
        }
    }

    public void l(ViewGroup viewGroup) {
        if (viewGroup.getId() == -1) {
            StringBuilder stringBuilder = new StringBuilder();
            stringBuilder.append("ViewPager with adapter ");
            stringBuilder.append(this);
            stringBuilder.append(" requires a view id");
            throw new IllegalStateException(stringBuilder.toString());
        }
    }
}
